package demo.intro;
import java.lang.invoke.MethodHandles;


public class FuncTimeCost {
    public static void loop()
    {
        // 模拟一个业务场景...
        int cnt = 0;
        for(int i=0; i < 1e9; i++)
        {
            cnt++;
        }
    }
    
    public static void timecost_test0(){
        long start = System.currentTimeMillis();  // 时间开始
        loop();     // 执行代码块
        long end = System.currentTimeMillis();   //  时间结束
        System.out.println("func time costs "+ (end - start) + " ms");
    }
    
    @Timer
    public static void loop1()
    {
        loop();
    }
    @Timer
    public static void loop2()
    {
        loop();
    }
    public static void timecost_test1()
    {
        TimerUtil tu = new TimerUtil();
        String className = MethodHandles.lookup().lookupClass().getName(); // 获取当前类名
        tu.TimeCostSt(className);
    }

    public static void main(String[] args) {
        timecost_test0();
        timecost_test1();
        
    }

}

